home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / naming / CompoundName.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  3.6 KB  |  153 lines

  1. package javax.naming;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.io.ObjectOutputStream;
  6. import java.io.StreamCorruptedException;
  7. import java.util.Enumeration;
  8. import java.util.Properties;
  9.  
  10. public class CompoundName implements Name {
  11.    protected transient NameImpl impl;
  12.    protected transient Properties mySyntax;
  13.    private static final long serialVersionUID = 3513100557083972036L;
  14.  
  15.    protected CompoundName(Enumeration<String> var1, Properties var2) {
  16.       if (var2 == null) {
  17.          throw new NullPointerException();
  18.       } else {
  19.          this.mySyntax = var2;
  20.          this.impl = new NameImpl(var2, var1);
  21.       }
  22.    }
  23.  
  24.    public CompoundName(String var1, Properties var2) throws InvalidNameException {
  25.       if (var2 == null) {
  26.          throw new NullPointerException();
  27.       } else {
  28.          this.mySyntax = var2;
  29.          this.impl = new NameImpl(var2, var1);
  30.       }
  31.    }
  32.  
  33.    public String toString() {
  34.       return this.impl.toString();
  35.    }
  36.  
  37.    public boolean equals(Object var1) {
  38.       return var1 != null && var1 instanceof CompoundName && this.impl.equals(((CompoundName)var1).impl);
  39.    }
  40.  
  41.    public int hashCode() {
  42.       return this.impl.hashCode();
  43.    }
  44.  
  45.    public Object clone() {
  46.       return new CompoundName(this.getAll(), this.mySyntax);
  47.    }
  48.  
  49.    public int compareTo(Object var1) {
  50.       if (!(var1 instanceof CompoundName)) {
  51.          throw new ClassCastException("Not a CompoundName");
  52.       } else {
  53.          return this.impl.compareTo(((CompoundName)var1).impl);
  54.       }
  55.    }
  56.  
  57.    public int size() {
  58.       return this.impl.size();
  59.    }
  60.  
  61.    public boolean isEmpty() {
  62.       return this.impl.isEmpty();
  63.    }
  64.  
  65.    public Enumeration<String> getAll() {
  66.       return this.impl.getAll();
  67.    }
  68.  
  69.    public String get(int var1) {
  70.       return this.impl.get(var1);
  71.    }
  72.  
  73.    public Name getPrefix(int var1) {
  74.       Enumeration var2 = this.impl.getPrefix(var1);
  75.       return new CompoundName(var2, this.mySyntax);
  76.    }
  77.  
  78.    public Name getSuffix(int var1) {
  79.       Enumeration var2 = this.impl.getSuffix(var1);
  80.       return new CompoundName(var2, this.mySyntax);
  81.    }
  82.  
  83.    public boolean startsWith(Name var1) {
  84.       return var1 instanceof CompoundName ? this.impl.startsWith(var1.size(), var1.getAll()) : false;
  85.    }
  86.  
  87.    public boolean endsWith(Name var1) {
  88.       return var1 instanceof CompoundName ? this.impl.endsWith(var1.size(), var1.getAll()) : false;
  89.    }
  90.  
  91.    public Name addAll(Name var1) throws InvalidNameException {
  92.       if (var1 instanceof CompoundName) {
  93.          this.impl.addAll(var1.getAll());
  94.          return this;
  95.       } else {
  96.          throw new InvalidNameException("Not a compound name: " + var1.toString());
  97.       }
  98.    }
  99.  
  100.    public Name addAll(int var1, Name var2) throws InvalidNameException {
  101.       if (var2 instanceof CompoundName) {
  102.          this.impl.addAll(var1, var2.getAll());
  103.          return this;
  104.       } else {
  105.          throw new InvalidNameException("Not a compound name: " + var2.toString());
  106.       }
  107.    }
  108.  
  109.    public Name add(String var1) throws InvalidNameException {
  110.       this.impl.add(var1);
  111.       return this;
  112.    }
  113.  
  114.    public Name add(int var1, String var2) throws InvalidNameException {
  115.       this.impl.add(var1, var2);
  116.       return this;
  117.    }
  118.  
  119.    public Object remove(int var1) throws InvalidNameException {
  120.       return this.impl.remove(var1);
  121.    }
  122.  
  123.    private void writeObject(ObjectOutputStream var1) throws IOException {
  124.       var1.writeObject(this.mySyntax);
  125.       var1.writeInt(this.size());
  126.       Enumeration var2 = this.getAll();
  127.  
  128.       while(var2.hasMoreElements()) {
  129.          var1.writeObject(var2.nextElement());
  130.       }
  131.  
  132.    }
  133.  
  134.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  135.       this.mySyntax = (Properties)var1.readObject();
  136.       this.impl = new NameImpl(this.mySyntax);
  137.       int var2 = var1.readInt();
  138.  
  139.       try {
  140.          while(true) {
  141.             --var2;
  142.             if (var2 < 0) {
  143.                return;
  144.             }
  145.  
  146.             this.add((String)var1.readObject());
  147.          }
  148.       } catch (InvalidNameException var4) {
  149.          throw new StreamCorruptedException("Invalid name");
  150.       }
  151.    }
  152. }
  153.